//
//  AAAAA.m
//  Pods
//
//  Created by 帅 on 2021/11/3.
//

#import "AAAAA.h"

NSString *const HNNetWorkDEFAULTS_API_MODE_KEY = @"apiMode";

@interface AAAAA ()

@end


@implementation AAAAA


-(NSString *)Accept_Language{
    NSAssert(NO, @"HNNetWorkConfig Accept_Language 不能为空");
    return @"";
}

-(NSString *)AppId{
    NSAssert(NO, @"HNNetWorkConfig AppId 不能为空");
    return @"";
}

-(NSString *)UserAgent{
    NSAssert(NO, @"HNNetWorkConfig UserAgent 不能为空");
    return @"";
}

-(NSString *)UserToken{
    NSAssert(NO, @"HNNetWorkConfig UserToken 不能为空");
    return @"";
}

- (double)longitude{
    return 0;
}

- (double)latitude{
    return 0;
}


-(NSString *)stageURL{
    NSAssert(NO, @"HNNetWorkConfig stageURL 不能为空");
    return @"";
}

-(NSString *)stage2URL{
    NSAssert(NO, @"HNNetWorkConfig stage2URL 不能为空");
    return @"";
}

-(NSString *)devURL{
    NSAssert(NO, @"HNNetWorkConfig devURL 不能为空");
    return @"";
}

-(NSString *)productionURL{
    NSAssert(NO, @"HNNetWorkConfig productionURL 不能为空");
    return @"";
}

- (BOOL)isStage{
//    RACSignal * singe = [RACSignal createSignal:^RACDisposable * _Nullable(id<RACSubscriber>  _Nonnull subscriber) {
//
//    }];
    
    
    return NO;
}

//切换环境  切换链接
- (void)switchApiConfig:(HNApiMode)apiMode{
    _mode = apiMode;
    [self resetBaseUrlDefault:[self getOriginBaseUrl]];
    [self saveApiMode];
}

- (NSString *)getOriginBaseUrl {
    switch (self.mode) {
        case HNApiModeStage:
            return self.stageURL;
        case HNApiDev:
            return self.devURL;
        case HNApiModeStage2:
            return self.stage2URL;
        default:
            return self.productionURL;
    }
}

- (void)resetBaseUrlDefault:(NSString * _Nonnull)url{
    @synchronized (self) {
        _baseDefaultUrl = url;
    }
}

- (void)initApiMode {
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
#ifdef DEBUG
    HNApiMode mode = HNApiModeStage;
#else
    HNApiMode mode = self.isStage ? HNApiModeStage : HNApiModeProduction;
#endif
    
    if ([[defaults dictionaryRepresentation].allKeys containsObject:HNNetWorkDEFAULTS_API_MODE_KEY]) {
        mode = (HNApiMode) [defaults integerForKey:HNNetWorkDEFAULTS_API_MODE_KEY];
    }
    _mode = mode;
}

- (void)saveApiMode {
    [[NSUserDefaults standardUserDefaults] setInteger:self.mode forKey:HNNetWorkDEFAULTS_API_MODE_KEY];
    [[NSUserDefaults standardUserDefaults] synchronize];
}


-(NSMutableArray *)sDimainUrlArray{
    return [NSArray array];
}

- (void)testLog:(NSArray <NSArray *>*)allRangeArr{
    
    NSMutableArray *rowArr = [[NSMutableArray alloc]initWithObjects:allRangeArr[0][0],allRangeArr[1][0],allRangeArr[2][0], nil];

    //最小区间值
    NSArray *smallestRange = @[@(0),@(0)];
    int minV = 0;
    int maxV = INT_MIN;

    //二维数组标记点
    int allRangeArr_0 = 0;
    int allRangeArr_1 = 0;

    BOOL _slide = YES;
    
    while (_slide) {
        //求出最大值
        int maxValue = [[rowArr valueForKeyPath:@"@max.intValue"] intValue];
        maxV = maxValue;
      //求出最小值
        int minValue = [[rowArr valueForKeyPath:@"@min.intValue"] intValue];
        minV = minValue;
       
        //求出最小值-对应的坐标位置-然后将最小坐标值右移一位
        
        for (int i=0; i<rowArr.count; i++) {
            NSNumber * rowNum = rowArr[i];
            if (rowNum.intValue == minV) {
                //取出最小值对应二维数组的坐标
                NSArray *minArr = allRangeArr[i];
                allRangeArr_0 = i;
                allRangeArr_1 = (int)[minArr indexOfObject:rowNum];
                
                allRangeArr_1 ++;//坐标右移一位
                if (allRangeArr_1 >= minArr.count) {
                    //移动结束
                    _slide = NO;
                }else{
                    //将最小值右移一位
                    [rowArr replaceObjectAtIndex:allRangeArr_0 withObject:allRangeArr[allRangeArr_0][allRangeArr_1]];
                    
                }
                break;
            }
            
        }
    }
    
    smallestRange = @[@(minV),@(maxV)];
    
    NSLog(@"smallestRange=%@",smallestRange);

}


- (void)hahahahahahahahahahahhahahahahahahahahahaha{
    NSLog(@"aaadsdhasjkdhjkashdjksahjkdas");
}

@end
